using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using KEA.Core;


namespace KEA
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class Background : Microsoft.Xna.Framework.DrawableGameComponent
    {

        private ScrollingBackground mybackground;
        private Game1 game;
        public Background(Game1 agame)
            : base(agame)
        {
            game = agame;
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            mybackground = new ScrollingBackground();
            Texture2D background = game.Content.Load<Texture2D>("textures/bg");
            mybackground.Load(game.graphics, background);


            base.Initialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // The time since Update was called last.
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            mybackground.Update(elapsed * 100);


            base.Update(gameTime);
        }
        public override void Draw(GameTime gameTime)
        {
            game.spriteBatch.Begin();
            mybackground.Draw(game.spriteBatch);
            game.spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
